#include "contiki.h"
#include <stdio.h>

static process_event_t event_data_ready;

PROCESS(print_hello_process, "Hello");
PROCESS(print_world_process, "World");

AUTOSTART_PROCESSES(&print_hello_process, &print_world_process);

PROCESS_THREAD(print_world_process, ev, data)
{
	PROCESS_BEGIN();
	
	static struct etimer timer;
	
	etimer_set(&timer, CLOCK_CONF_SECOND);
	
	printf("*****print hello process start****\r\n");
	event_data_ready = process_alloc_event();
	
	while(1)
	{
		PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
		printf("Hello");
		process_post(&print_hello_process, event_data_ready, NULL);
		etimer_reset(&timer);
	}
	
	PROCESS_END();
	
}

PROCESS_THREAD(print_hello_process, ev, data)
{
	PROCESS_BEGIN();
	
	printf("****print world process start****\r\n");
	while(1)
	{
		PROCESS_WAIT_EVENT_UNTIL(ev == event_data_ready);
		printf("world\r\n");
	}
	
	PROCESS_END();
}